<template>
  <div class="overtime-setting">
    <form @submit.prevent="confirm" class="form">
      <div class="form-item middle-flex">
        <div class="label flex">
          <strong>基本工资</strong>
          <span>(元/月)</span>
        </div>
        <input v-model="data.baseSalary" type="number" placeholder="基本工资">
      </div>
      <div class="form-item middle-flex">
        <div class="label flex">
          <strong>加班工资</strong>
          <span>(元/小时)</span>
        </div>
        <input v-model="data.overtimeSalary" type="number" placeholder="加班工资">
      </div>

      <div class="form-item middle-flex btn-box">
        <button class="btn" type="submit">确认</button>
      </div>

    </form>
  </div>
</template>

<script>
import setting from './setting.js'

const { baseSalary = 0, overtimeSalary = 0 } = setting.get()

export default {
  data() {
    return {
      data: {
        baseSalary, overtimeSalary
      }
    }
  },
  methods: {
    confirm() {
      setting.set(this.data)
      this.$toast('设置成功')
      this.$router.push('overtime')
    }
  }
}
</script>

<style lang="scss" scoped>
.overtime-setting {
  min-height: 100vh;
  background: #f5f5f5;
}
.form {
  width: 100%;
  background: white;
}
.form-item {
  height: 1rem;
  border-bottom: 1px solid #eee;
  margin: 0 0.2rem;
  .label {
    white-space: nowrap;
  }
  input {
    text-align: right;
    border: none;
    font-size: 0.46rem;
    flex: 1;
    &::placeholder {
      font-size: 0.32rem;
    }
  }
}
.btn-box {
  padding: 0.5rem 0;
}
.btn {
  width: 80%;
  margin: 0 auto;
  display: block;
  outline: 0 none;
  box-sizing: border-box;
  padding: 0;
  text-align: center;
  font-size: 18px;
  height: 38px;
  line-height: 38px;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  white-space: nowrap;
  color: #fff;
  background-color: #108ee9;
  border: 1px solid #108ee9;
  border-radius: 5px;
}
</style>
